python pandas change or replace value or cell name
33
# 1. Replace a single value with a new value for an individual DataFrame column:
df['column name'] = df['column name'].replace(['old value'],'new value')
# 2. Replace multiple values with a new value for an individual DataFrame column:
df['column name'] = df['column name'].replace(['1st old value','2nd old value',...],'new value')
# 3. Replace multiple values with multiple new values for an individual DataFrame column:
df['column name'] = df['column name'].replace(['1st old value','2nd old value',...],['1st new value','2nd new value',...])
# 4. Replace a single value with a new value for an entire DataFrame:
df = df.replace(['old value'],'new value')